<?php
	mysql_connect("localhost", "root", "%Tg34fv1")or die("cannot connect"); 
	function wwdb() {
		connectdb("wordWaffle");
	}
	function membersdb() {
		connectdb("membersDB");
	}
	function connectdb($dbname) {
		mysql_select_db($dbname) or die("cannot select $dbname");
	}
	function cleanparam($param) {
		return mysql_real_escape_string(stripslashes($_GET[$param]));
	}
	function validateKey($myKey) {
		wwdb();
		if ($myKey == null) return null;
		$result=mysql_query("SELECT * FROM players WHERE sesskey=$myKey");
		if ($row = mysql_fetch_assoc($result))
			return $row["memberID"];
		else //unrecognized session key!
			return null;
	}
	function validateGameID($gameID) {
		wwdb();
		$results = mysql_query("SELECT * FROM gameStatus WHERE gameID=$gameID");
		if ($row = mysql_fetch_assoc($results)) return $row["status"];
		else return false;
	}
?>